const fs = require('fs');
const path = require('path');

// 生成构建信息
const buildInfo = {
    buildTime: new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }),
    version: process.env.npm_package_version || '1.1.1'
};

// 将构建信息写入到 src/config 目录
const configDir = path.join(__dirname, '../src/config');
if (!fs.existsSync(configDir)) {
    fs.mkdirSync(configDir, { recursive: true });
}

// 写入构建信息文件
fs.writeFileSync(
    path.join(configDir, 'build-info.json'),
    JSON.stringify(buildInfo, null, 2)
);
